package com.yf.exam.modules.trainingarchives.worktype.controller;

import com.yf.exam.common.entity.Result;
import com.yf.exam.modules.trainingarchives.trainingclassschedule.dto.resp.TrainingClassScheduleRespDTO;
import com.yf.exam.modules.trainingarchives.worktype.dto.req.OrgWorkTypeReqDTO;
import com.yf.exam.modules.trainingarchives.worktype.dto.resp.OrgWorkTypeRespDTO;
import com.yf.exam.modules.trainingarchives.worktype.service.OrgWorkTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工种表(OrgWorkType)表控制层
 *
 * @author gengjiaxuan
 * @since 2025-01-15 22:14:18
 */
@Api(tags={"工种"})
@RestController
@RequestMapping("/orgWorkType")
@Slf4j
public class OrgWorkTypeController {
    /**
     * 服务对象
     */
    @Resource
    private OrgWorkTypeService orgWorkTypeService;

    /**
     * 下拉框列表
     * @return
     */
    @ApiOperation(value = "工种下拉框列表")
    @PostMapping("/list")
    public Result<List<TrainingClassScheduleRespDTO>> getList() {
        try {
            //分页查询并转换
            List<OrgWorkTypeRespDTO> page = orgWorkTypeService.getlist();
            return Result.ok(page);
        } catch (Exception e) {
            log.error("OrgWorkTypeController.getList.error:{}", e.getMessage(), e);
            return Result.faild("查询失败");
        }
    }

}

